package com.javablog.redis.demo.lock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @wenrong.yu
 *
 */
@Component
public class RedisLock {

    public static final String LOCK = "lock_protect";

    @Autowired
    private LockRepository lockRepository;

    public Lock getLock(String key) {
        String requestId = UUID.randomUUID().toString();
        return new Lock(lockRepository, key+":" + LOCK, requestId);
    }
}
